package oj;

import java.util.Scanner;

public class Day8F {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()){
            int a=sc.nextInt();
            String[] str=new String[a];
            for (int i = 0; i < a; i++) {
                str[i]=sc.next();
            }
           if(length(str) && lexi(str)){
               System.out.println("both");
           }else if(!lexi(str) && !length(str)){
               System.out.println("none");
           }else if(length(str)){
               System.out.println("lengths");
           }else{
               System.out.println("lexicographically");
           }
        }
    }
    public static boolean length(String[] str){
        int len=0;
        for (String s:str){
            if(s.length()>len){
                len=s.length();
            }else {
                return false;
            }
        }
        return true;
    }
    public static boolean lexi(String[] str){
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].compareTo(str[i+1])>0){
                return false;
            }
        }
return true;
    }
}
